package gamer;

import java.io.IOException;

import dispatcher.ClientDispatcher;
import dispatcher.InterfaceDispatcher;

import IHM.IHM;
/**
 * 
 * @author LocoRocoBattleStein
 *
 */
public class Player extends Gamer{
	
	private IHM ihm;
	/**
	 * Constructor
	 * @param id
	 * @param pseudo
	 * @param dp
	 * @param location
	 */
	public Player(int id, String pseudo, InterfaceDispatcher dp, int location) throws IOException {
		super(id, pseudo, dp);
		ihm = new IHM(id, this.getDp(), this.getBw(), this.getMoney(), location);
		ihm.setTitle("BattleStein");
		ihm.setSize(ihm.getWScreen(), ihm.getHScreen());   
		ihm.setVisible(true);
	}
	
	public void	play() throws IOException {
		ihm.update();
	}
	
	public void startGame(int idPlayer) {
		this.id = idPlayer;
		ihm.start();
	}
	
	public void updateTower(int id, int idPlayer, int x, int y) {
		bw.getTower_manager().addTower(id, idPlayer, x, y);
		ihm.buyTower();
	}
	
	public static void main(String[] args) throws IOException {
		ClientDispatcher dp = new ClientDispatcher("10.2.1.10", 3002);
		Player p = new Player(1,"player", dp, 1);
		dp.setGamer(p);
		while(true) {
			p.play();
		}
	}

}
